package com.project.lk.nurseapp.nurse;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;

import com.project.lk.nurseapp.R;
import com.project.lk.nurseapp.common.adapter.BaseRecycleViewAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 功能介绍：
 * 项目名：
 * 模块名称：
 * 作者：LK
 * 日期：2018/1/9
 * 修改日期：
 */
public class CommentStartAdapter extends BaseRecycleViewAdapter {

    List<CommentStartBean> mList = new ArrayList<>();
    Context mContext;

    int savePosition;
    public CommentStartAdapter(List<CommentStartBean> list, Context context) {
        this.mList = list;
        this.mContext = context;
    }

    public void setmList(List<CommentStartBean> list){
        this.mList=list;
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_comment_start_layout, parent, false);
        ViewHolder viewHolder=new ViewHolder(view);
        return viewHolder;
    }
    public interface  ItemEventListenter{
        void start(int position);
    }
    ItemEventListenter mListenter;
    public void setItemEvent(ItemEventListenter listenter){
        this.mListenter=listenter;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
        final ViewHolder viewHolder=(ViewHolder)holder;

        viewHolder.itemStart.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                    mListenter.start(position);
               }
        });
        Log.e("MLOG",mList.get(position).isStart()+"");
        viewHolder.itemStart.setChecked(mList.get(position).isStart());
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.item_start)
        CheckBox itemStart;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
